import 'package:spring_fairy/model/mood_point_image.dart';


///记录点
class MoodTrackPoint {
  int? id;
  int? trackId;
  int? moodTypeId;
  int? moodLevel;
  String? description;
  double? latitude;
  double? longitude;
  String? locationName;
  DateTime? moodTime;
  String? weather;
  double? temperature;
  DateTime? createdAt;

  List<MoodPointImage>? images;

  MoodTrackPoint({
    this.id,
    this.trackId,
    this.moodTypeId,
    this.moodLevel,
    this.description,
    this.latitude,
    this.longitude,
    this.locationName,
    this.moodTime,
    this.weather,
    this.temperature,
    this.createdAt,
  });

  factory MoodTrackPoint.fromJson(Map<String, dynamic> json) => MoodTrackPoint(
    id: json['id'],
    trackId: json['track'] ,
    moodTypeId: json['moodTypeId'],
    moodLevel: json['moodLevel'],
    description: json['description'],
    latitude: (json['latitude'] as num?)?.toDouble(),
    longitude: (json['longitude'] as num?)?.toDouble(),
    locationName: json['locationName'],
    moodTime: json['moodTime'] != null ? DateTime.parse(json['moodTime']) : null,
    weather: json['weather'],
    temperature: (json['temperature'] as num?)?.toDouble(),
    createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null,
  );

  Map<String, dynamic> toJson() => {
    'id': id,
    'trackId': trackId,
    'moodTypeId': moodTypeId,
    'moodLevel': moodLevel,
    'description': description,
    'latitude': latitude,
    'longitude': longitude,
    'locationName': locationName,
    'moodTime': moodTime?.toIso8601String(),
    'weather': weather,
    'temperature': temperature,
    'createdAt': createdAt?.toIso8601String(),
  };

  @override
  String toString() {
    return 'MoodTrackPoint{id: $id, trackId: $trackId, moodTypeId: $moodTypeId, moodLevel: $moodLevel, description: $description, latitude: $latitude, longitude: $longitude, locationName: $locationName, moodTime: $moodTime, weather: $weather, temperature: $temperature, createdAt: $createdAt, images: $images}';
  }

  @override
  bool operator ==(Object other) {
    if(other is! MoodTrackPoint) {
      return false;
    }
    return other.id == id;
  }

  @override
  int get hashCode => id!;
}
